Source for file DeleteFolder.php

Documentation is available at DeleteFolder.php

  1. <?php /*
  2.  * FCKeditor - The text editor for internet
  3.  * Copyright (C) 2003-2005 Frederico Caldeira Knabben
  4.  * 
  5.  * Licensed under the terms of the GNU Lesser General Public License:
  6.  *         http://www.opensource.org/licenses/lgpl-license.php
  7.  * 
  8.  * For further information visit:
  9.  *         http://www.fckeditor.net/
  10.  * 
  11.  * File Name: DeleteFolder.php
  12.  *     Implements the DeleteFolder command to delete a folder
  13.  *     in the current directory. Output is in XML.
  14.  * 
  15.  * File Authors:
  16.  *         Grant French (grant@mcpuk.net)
  17.  */
  18. class DeleteFolder {
  19.     var $fckphp_config;
  20.     var $type;
  21.     var $cwd;
  22.     var $actual_cwd;
  23.     var $newfolder;
  24.     
  25.     function DeleteFolder($fckphp_config,$type,$cwd{
  26.         $this->fckphp_config=$fckphp_config;
  27.         $this->type=$type;
  28.         $this->raw_cwd=$cwd;
  29.         $this->actual_cwd=str_replace("//","/",($this->fckphp_config['UserFilesPath']."/$type/".$this->raw_cwd));
  30.         $this->real_cwd=str_replace("//","/",($this->fckphp_config['basedir']."/".$this->actual_cwd));
  31.         $this->foldername=str_replace(array("..","/"),"",$_GET['FolderName']);
  32.     }
  33.     
  34.     function run({
  35.         
  36.         if ($this->delDir($this->real_cwd.'/'.$this->foldername)) {
  37.             $err_no=0;
  38.         else {
  39.             $err_no=402;
  40.         }
  41.         
  42.         header ("content-type: text/xml");
  43.         echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
  44.         ?>
  45. <Connector command="DeleteFolder" resourceType="<?php echo $this->type?>">
  46.     <CurrentFolder path="<?php echo $this->raw_cwd?>" url="<?php echo $this->actual_cwd?>" />
  47.     <Error number="<?php echo "".$err_no?>" />
  48. </Connector>
  49.         <?php
  50.     }
  51.     
  52.     
  53.     function delDir($dir{
  54.         $dh=opendir($dir);
  55.         if ($dh{
  56.             while ($entry=readdir($dh)) {
  57.                 if (($entry!=".")&&($entry!="..")) {
  58.                     if (is_dir($dir.'/'.$entry)) {
  59.                         $this->delDir($dir.'/'.$entry);    
  60.                     else {
  61.                         $thumb=$dir.'/.thumb_'.$entry;
  62.                         if (file_exists($thumb)) if (!unlink($thumb)) return false;
  63.                         if (!unlink($dir.'/'.$entry)) return false;
  64.                     }
  65.                 }
  66.             }    
  67.             closedir($dh);
  68.             return rmdir($dir);
  69.         else {
  70.             return false;
  71.         }
  72.     }
  73. }
  74.  
  75. ?>

Documentation generated on Mon, 05 May 2008 16:19:14 +0400 by phpDocumentor 1.4.0